﻿<Window x:Class="TestApplication.VirtualizationTreeViewTest"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="http://schemas.AvalonControls/AvalonControlsLibrary/Controls"
    Title="VirtualizationTreeViewTest" Height="500" Width="600">
    <Window.Resources>
        <!--Colors section-->
        <SolidColorBrush x:Key="SolidBlack" Color="Black"/>
        <SolidColorBrush x:Key="SolidSilver" Color="Silver"/>
        <SolidColorBrush x:Key="SolidWhite" Color="White"/>

        <Style x:Key="ExpandCollapseToggleStyle"
			TargetType="{x:Type ToggleButton}">
            <Setter Property="Focusable"
					Value="False"/>
            <Setter Property="Width"
					Value="19"/>
            <Setter Property="Height"
					Value="13"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border Width="19"
								Height="13">
                            <Border Width="9"
									Height="9"
									CornerRadius="1"
									SnapsToDevicePixels="true"
                  Background="{StaticResource SolidSilver}">
                                <Path x:Name="ExpandPath"
									  Margin="2,1,1,1"
									  Fill="{StaticResource SolidWhite}"
									  Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"/>
                            </Border>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked"
									 Value="True">
                                <Setter Property="Data"
										TargetName="ExpandPath"
										Value="M 0 2 L 0 3 L 5 3 L 5 2 Z"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!--Style for the TreeListBoxItem-->
        <Style TargetType="{x:Type local:TreeListBoxItem}" x:Key="{x:Type local:TreeListBoxItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:TreeListBoxItem}">
                        <Border Name="Bd"
                      Background="{TemplateBinding Background}"
                      BorderBrush="{TemplateBinding BorderBrush}"
                      BorderThickness="{TemplateBinding BorderThickness}"
                      Padding="{TemplateBinding Padding}">
                            <WrapPanel DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:TreeListBoxItem}}}">
                                <!--Button to show the + sign-->
                                <ToggleButton x:Name="PART_Header"
                              Style="{StaticResource ExpandCollapseToggleStyle}"
                              ClickMode="Press"/>
                                <ContentPresenter />
                            </WrapPanel>
                        </Border>

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected"
									 Value="true">
                                <Setter TargetName="Bd"
										Property="Background"
										Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                                <Setter Property="Foreground"
										Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
                            </Trigger>
                            <Trigger Property="IsEnabled"
									 Value="false">
                                <Setter Property="Foreground"
										Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="9*"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.Resources>
            <!--<Style TargetType="{x:Type local:TreeListBoxItem}" x:Key="{x:Type local:TreeListBoxItem}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Content.MyProperty}"
                                 Value="True">
                        <Setter Property="Visibility" Value="Collapsed"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>-->
        </Grid.Resources>
        
        <local:TreeListBox Name="treeListBox">
            <local:TreeListBox.ItemTemplate>
                <DataTemplate>
                    <Border Height="20" Background="AliceBlue">
                        <TextBlock Text="{Binding Path=MyProperty}"/>
                    </Border>
                </DataTemplate>
            </local:TreeListBox.ItemTemplate>
            
        </local:TreeListBox>

        <StackPanel Grid.Row="1" >
            <Button Content="Bulk Insert" Click="BulkInsertClick"/>
            <TextBlock Name="visualCount"/>
        </StackPanel>

    </Grid>
</Window>
